Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IntelliJ reacts to attribution enable/disable from site config #318

Merged
merged 10 commits into from
Feb 2, 2024

Conversation

cbart
Copy link
Contributor

@cbart cbart commented Jan 19, 2024

Closes sourcegraph/sourcegraph#59427

This change adds CurrentConfigFeatures singleton/observer that allows the UI to react on whether attribution is turned on or off.

Background:

  • Attribution search (RFC WIP, PRD) is performing a dotcom search on a snippet of code generated by Cody
  • The goal is to inform the user that this code was found in the open source.
  • For chat, this looks like an indicator - we show the user that search is running and then
    • either it finds nothing - then we signal there is no risk
    • or it finds the snippet - then we signal where the snippet was found in tooltip
    • or it cannot finish the search - then we show attribution is not available

TODO

  • unit tests!!!
  • green SCIP CI

Test plan

  • TODO
  • Corresponding VS Code tests
  • Manual
  • Loom

@cbart
Copy link
Contributor Author

cbart commented Jan 22, 2024

All comments addressed, please take another look! This should be good to review now.

@cbart cbart marked this pull request as ready for review January 22, 2024 13:36
@cbart cbart changed the title IntelliJ enables attribution in Chat based on site config IntelliJ reacts to attribution enable/disable from site config Jan 26, 2024
@cbart cbart force-pushed the cb/59427/chat-attribution-ui-based-on-site-config branch from b9ef3a7 to 623d90a Compare January 31, 2024 09:27
@cbart cbart force-pushed the cb/59427/chat-attribution-ui-based-on-site-config branch from 623d90a to 6ffbe11 Compare January 31, 2024 09:29
* Given listener will be given new {@link ConfigFeatures} whenever they arrive. Observation
* relationship is ended once the returned cleanup {@link Runnable} is {@link Runnable#run()}.
*/
public Runnable attach(ConfigFeaturesObserver observer) {
Copy link
Contributor

@pkukielka pkukielka Jan 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor thing, but you could use CancellationToken here.

val cancellationToken = CancellationToken()
cancellationToken.onCancel { observers.remove(id) }
return cancellationToken

A bit more code but I think it is a bit more clear regarding the intent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Contributor

@pkukielka pkukielka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cbart cbart merged commit 6349fcc into main Feb 2, 2024
1 of 2 checks passed
@cbart cbart deleted the cb/59427/chat-attribution-ui-based-on-site-config branch February 2, 2024 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Guardrails can be turned on/off from enterprise instance
2 participants